<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.org/ui">

    <f:view contentType="text/html">
        <h:head>
            <f:facet name="first">
                <meta content='text/html; charset=UTF-8' http-equiv="Content-Type"/>
                <title>Crew Intranet: Voir détails d'un véhicule</title>
            </f:facet>
        </h:head> 

        <h:body>
            <ui:composition template="./template.xhtml">
                <ui:define name="top">

                </ui:define>
                <ui:define name="left">
                    <h:form >
                        <p:menu my="true" style="width:200px">
                            <p:submenu label="Navigation Véhicle" >  
                                <p:menuitem value="Les véhicules" action="#{redirectionBean.getRedirectionAccueilVehicule}" icon="ui-icon-home"
                                            styleClass="#{view.viewId == '/accueilVehicule.xhtml' || 
                                                          view.viewId == '/creerUnVehicule.xhtml' || 
                                                          view.viewId == '/detailVehicule.xhtml' || 
                                                          view.viewId == '/detailVehiculeView.xhtml' || 
                                                          view.viewId == '/editerUnlVehicule.xhtml' ? 'ui-state-active' : ''}"
                                            />  
                            </p:submenu>
                            <p:submenu label="Navigation Catégorie">  
                                <p:menuitem value="Gestion des modèles" action="#{redirectionBean.getRedirectionGestionMarque}" icon="ui-icon-suitcase" 
                                            styleClass="#{ view.viewId == '/gestionMarque.xhtml' ? 'ui-state-active' : ''}"
                                            />  
                            </p:submenu>  
                            <p:submenu label="Navigation Réglage">  
                                <p:menuitem value="Réglage formulaire" action="#" icon="ui-icon-gear"/>  
                            </p:submenu>  
                        </p:menu>
                    </h:form>
                </ui:define>
                <ui:define name="content">
                    <h:form id="formMessage">
                        <p:growl id="messageGrow" /> 
                        <p:growl id="messageGrowDetail"  />

                    </h:form>
                    <h:form id="formAjouterVehicule">
                        <p:panel  style="width: 95%">
                            <f:facet name="header">
                                Editer, modifier et ajouter des informations sur un vehicule
                                <p:commandButton style="float: right; color: red;" value="Retour" title="Retour à la liste des employés" 
                                                 action="#{vehiculeCreerBean.retourDansListe}"
                                                 immediate="true"
                                                 icon="ui-icon-arrowreturnthick-1-w"/>
                                <p:commandButton icon="ui-icon-disk" value="Enregistrer les modifications" 
                                                 action="#{vehiculeEditBean.enregistrerLesModification}"
                                                 update=":formMessage:messageGrowDetail, @form"
                                                 immediate="true"
                                                 style="color: green; float: right;"/>

                            </f:facet>
                            <div class="alert alert-danger"><strong>* Cliquer</strong> sur les zones en <strong>rouge</strong> pour les modifier!</div>
                            <p:accordionPanel multiple="false">  
                                <p:tab title="Informations de générales" id="InfosPersoTab">
                                    <p:panelGrid columns="2">

                                        <h:outputLabel value="Numéro CGG" for="numerocgg" />
                                        <p:inplace id="numerocgg" editor="true" style="color: tomato;" effectSpeed="fast">  
                                            <p:inputText value="#{vehiculeEditBean.cvVehiculeSelectionner.numerocgg}" style="width: 150px;" 
                                                         required="true" label="text"/>  
                                        </p:inplace>

                                        <h:outputLabel value="Numéro de chassis:" for="numeroshassis" />
                                        <p:inplace id="numeroshassis" editor="true" style="color: tomato;" effectSpeed="fast">  
                                            <p:inputText value="#{vehiculeEditBean.cvVehiculeSelectionner.numeroshassis}" style="width: 150px;" 
                                                         required="true" label="text"/>  
                                        </p:inplace>

                                        <h:outputLabel value="Numéro matricule:" for="numeroimatriculation" />
                                        <p:inplace id="numeroimatriculation" editor="true" style="color: tomato;" effectSpeed="fast">  
                                            <p:inputText value="#{vehiculeEditBean.cvVehiculeSelectionner.numeroimatriculation}" style="width: 150px;"  
                                                         required="true" label="text"/>  
                                        </p:inplace>

                                        <h:outputLabel value="Annee de construction:" for="anneeconstruction" />
                                        <p:inplace id="anneeconstruction" editor="true" style="color: tomato;" effectSpeed="fast">  
                                            <p:inputMask value="#{vehiculeEditBean.cvVehiculeSelectionner.anneeconstruction}" style="width: 150px;"  
                                                         mask="9999"
                                                         required="true" label="text"/>  
                                        </p:inplace>

                                        <h:outputLabel value="Nom:" for="nom" />
                                        <p:inplace id="nom" editor="true" style="color: tomato;" effectSpeed="fast">  
                                            <p:inputText value="#{vehiculeEditBean.cvVehiculeSelectionner.nom}" style="width: 150px;"  
                                                         required="true" label="text"/>  
                                        </p:inplace>

                                        <h:outputLabel value="Categorie du vehicule:" for="categorievehicule" />
                                        <p:inplace id="categorievehicule" editor="true" style="color: tomato;" effectSpeed="fast">  
                                            <p:selectOneMenu 
                                                value="#{vehiculeEditBean.cvVehiculeSelectionner.categorievehicule}" 
                                                style="width: 70px;"
                                                required="true" >
                                                <f:selectItem itemLabel="Selectionner une catégorie" itemValue=""  />  
                                                <f:selectItems value="#{vehiculeCreerBean.listeCategorieVehicule}" var="categorie" itemLabel="#{categorie}" itemValue="#{categorie}" />
                                            </p:selectOneMenu>
                                        </p:inplace>


                                    </p:panelGrid>
                                </p:tab>
                                <p:tab title="Informations sur le modèles" id="InfosModeleTab">
                                    <p:panelGrid columns="2">
                                        <p:panelGrid columns="2">


                                            <h:outputLabel value="Marque :" for="cvMarqueIdmarque" />
                                            <h:outputText id="cvMarqueIdmarque" value="#{vehiculeEditBean.cvVehiculeSelectionner.typemodel.cvModelIdmodel.cvMarqueIdmarque.marque}"  />

                                            <h:outputLabel value="Modèle :" for="cvModelIdmodel" />
                                            <h:outputText id="cvModelIdmodel" value="#{vehiculeEditBean.cvVehiculeSelectionner.typemodel.cvModelIdmodel.model}" />

                                            <h:outputLabel value="Type modèle :" for="typemodel" />
                                            <h:outputText id="typemodel"  value="#{vehiculeEditBean.cvVehiculeSelectionner.typemodel.model}" />

                                        </p:panelGrid>
                                        <p:panelGrid columns="2">
                                            <p:commandButton id="changerModele" value="Modifier le modèle du vehicule" style="float: right;"  icon="ui-icon-plus"
                                                             update=":formDialogEditer:formChangementModelDialog"
                                                             immediate="true"
                                                             oncomplete="changementModeleDialog.show()"
                                                             />
                                        </p:panelGrid>
                                    </p:panelGrid>
                                </p:tab>
                                <p:tab title="Informations passager" id="InfosPassagerTab">
                                    <p:panelGrid columns="2">
                                        <h:outputLabel value="Place de Conducteur:" for="placeConducteur" />
                                        <p:inplace id="placeConducteur" editor="true" style="color: tomato;" effectSpeed="fast">  
                                            <p:spinner  value="#{vehiculeEditBean.cvVehiculeSelectionner.placeConducteur}"
                                                        style="width: 150px;" 
                                                        title="PlaceConducteur" min="1" max="4" />  
                                        </p:inplace>

                                        <h:outputLabel value="Place de Passager devant:" for="placePassagerdevant" />
                                        <p:inplace id="placePassagerdevant" editor="true" style="color: tomato;" effectSpeed="fast">  
                                            <p:spinner  value="#{vehiculeEditBean.cvVehiculeSelectionner.placePassagerdevant}" 
                                                        style="width: 150px;" 
                                                        title="PlacePassagerdevant" min="0" max="4"/>
                                        </p:inplace>

                                        <h:outputLabel value="PlacePassagerarriere:" for="placePassagerarriere" />
                                        <p:inplace id="placePassagerarriere" editor="true" style="color: tomato;" effectSpeed="fast">  
                                            <p:spinner  value="#{vehiculeEditBean.cvVehiculeSelectionner.placePassagerarriere}" 
                                                        style="width: 150px;" 
                                                        title="PlacePassagerarriere" min="0" max="4"/>
                                        </p:inplace>

                                        <h:outputLabel value="Appui tête" for="apuitete"  />
                                        <p:inplace id="apuitete" editor="true" style="color: tomato;" effectSpeed="fast">  
                                            <p:selectOneRadio   style="width:200px" value="#{vehiculeEditBean.cvVehiculeSelectionner.apuitete}" required="true" >
                                                <f:selectItem itemLabel="Oui" itemValue="oui"  />  
                                                <f:selectItem itemLabel="Non" itemValue="non"  />  
                                            </p:selectOneRadio>
                                        </p:inplace>


                                        <h:outputLabel value="Ceinture 3 points au milieu ::" for="ceinture" />
                                        <p:inplace id="ceinture" editor="true" style="color: tomato;" effectSpeed="fast">  
                                            <p:selectOneMenu  style="width:200px" value="#{vehiculeEditBean.cvVehiculeSelectionner.ceinture}" required="true" >
                                                <f:selectItem itemLabel="Selectionner" itemValue=""  />  
                                                <f:selectItems value="#{vehiculeCreerBean.listeCeinture}" var="ceinture" itemLabel="#{ceinture}" itemValue="#{ceinture}" />
                                            </p:selectOneMenu>
                                        </p:inplace>
                                    </p:panelGrid>
                                </p:tab>
                                <p:tab title="Informations Administrative" id="InfosAdminTab">
                                    <p:panelGrid columns="2">

                                        <h:outputLabel value="Numéro de carte grise:" for="cvAdministratifvehiculecol" />
                                        <p:inplace id="cvAdministratifvehiculecol" editor="true" style="color: tomato;" emptyLabel="Cliquez pour editer" effectSpeed="fast">  
                                            <p:inputText  value="#{vehiculeEditBean.cvVehiculeSelectionner.cvAdministratifvehicule.cvAdministratifvehiculecol}" 
                                                          style="width: 150px;" 
                                                          title="CvAdministratifvehiculecol" />
                                        </p:inplace>
                                        <h:outputLabel value="Date de Delivrance:" for="cartegriseDelivrance" />
                                        <p:inplace id="cartegriseDelivrance" editor="true" style="color: tomato;" emptyLabel="Cliquez pour editer"  effectSpeed="fast"  >  
                                            <p:calendar  value="#{vehiculeEditBean.cvVehiculeSelectionner.cvAdministratifvehicule.cartegriseDelivrance}"  pattern="dd/MM/yyyy"
                                                         navigator="true"
                                                         >
                                                <f:convertDateTime pattern="dd/MM/yyyy" />
                                            </p:calendar>

                                        </p:inplace> 

                                        <h:outputLabel value="Date d'expiration:" for="cartegriseExpiration" />

                                        <p:inplace id="cartegriseExpiration" editor="true" style="color: tomato;" emptyLabel="Cliquez pour editer"  effectSpeed="fast"  >  
                                            <p:calendar  value="#{vehiculeEditBean.cvVehiculeSelectionner.cvAdministratifvehicule.cartegriseExpiration}"  pattern="dd/MM/yyyy"
                                                         navigator="true"  >
                                                <f:convertDateTime pattern="dd/MM/yyyy" />
                                            </p:calendar>

                                        </p:inplace> 

                                        <h:outputLabel value="AssuranceCompagnie:" for="assuranceCompagnie" />
                                        <p:inplace id="assuranceCompagnie" editor="true" style="color: tomato;" emptyLabel="Cliquez pour editer" effectSpeed="fast">  
                                            <p:inputText  value="#{vehiculeEditBean.cvVehiculeSelectionner.cvAdministratifvehicule.assuranceCompagnie}" 
                                                          style="width: 150px;" 
                                                          title="AssuranceCompagnie" />
                                        </p:inplace>

                                        <h:outputLabel value="Prise d'effet:" for="assuranceEffet" />
                                        <p:inplace id="assuranceEffet" editor="true" style="color: tomato;" emptyLabel="Cliquez pour editer"  effectSpeed="fast"  >  
                                            <p:calendar  value="#{vehiculeEditBean.cvVehiculeSelectionner.cvAdministratifvehicule.assuranceEffet}"  pattern="dd/MM/yyyy"
                                                         navigator="true"
                                                         >
                                                <f:convertDateTime pattern="dd/MM/yyyy" />
                                            </p:calendar>

                                        </p:inplace> 

                                        <h:outputLabel value="Date d'expiration:" for="assuranceExpiration" />

                                        <p:inplace id="assuranceExpiration" editor="true" style="color: tomato;" emptyLabel="Cliquez pour editer"  effectSpeed="fast"  >  
                                            <p:calendar  value="#{vehiculeEditBean.cvVehiculeSelectionner.cvAdministratifvehicule.assuranceExpiration}"  pattern="dd/MM/yyyy"
                                                         navigator="true"
                                                         >
                                                <f:convertDateTime pattern="dd/MM/yyyy" />
                                            </p:calendar>

                                        </p:inplace>
                                    </p:panelGrid>
                                </p:tab>
                            </p:accordionPanel> 
                        </p:panel>
                    </h:form>
                    <h:form id="formDialogEditer">
                        <p:dialog header="Changement du modèle" widgetVar="changementModeleDialog" resizable="false" id="changementModeleDialogId"  
                                  hideEffect="explode" showEffect="slide" >  
                            <h:form id="formChangementModelDialog">
                                <p:panelGrid columns="2" >
                                    <h:outputLabel value="Marque :" for="cvMarqueIdmarque" />
                                    <p:selectOneMenu id="cvMarqueIdmarque" style="width:200px" required="true" value="#{vehiculeCreerBean.cvMarque}" converter="marqueConverter" >
                                        <f:selectItem itemLabel="Selectionne marque" itemValue="" />  
                                        <f:selectItems value="#{gestionVehiculeBean.listeMarque}" var="marque" itemLabel="#{marque.marque}" itemValue="#{marque}"/>  
                                        <p:ajax update="cvModelIdmodel"
                                                listener="#{vehiculeCreerBean.handleMarqueChange}" />  
                                    </p:selectOneMenu>

                                    <h:outputLabel value="Modèle :" for="cvModelIdmodel" />
                                    <p:selectOneMenu id="cvModelIdmodel" style="width:200px" required="true" value="#{vehiculeCreerBean.cvModel}" converter="modeleConverter"  >

                                        <f:selectItem itemLabel="Selectionner modèle" itemValue="" />  
                                        <f:selectItems value="#{vehiculeCreerBean.modelListeHand}" var="modele" itemLabel="#{modele.model}" itemValue="#{modele}" />  

                                        <p:ajax update="typemodel" 
                                                listener="#{vehiculeCreerBean.handleModeleChange}" />
                                    </p:selectOneMenu>
                                    <h:outputLabel value="Type modèle :" for="typemodel" />
                                    <p:selectOneMenu id="typemodel" style="width:200px" value="#{vehiculeCreerBean.cvTypemodel}" required="true" converter="typemodeleConverter"  >
                                        <f:selectItem itemLabel="Selectionner un type de modèle" itemValue="" />  
                                        <f:selectItems value="#{vehiculeCreerBean.typemodelListeHand}" var="tyemodele" itemLabel="#{tyemodele.model}" itemValue="#{tyemodele}" />  
                                    </p:selectOneMenu>
                                    <h:outputText />
                                    <p:commandButton value="Valider le modèle" icon="ui-icon-check"
                                                     action="#{vehiculeEditBean.nouveauModele}"
                                                     update=":formDialogEditer:formChangementModelDialog, :formMessage:messageGrow, :formAjouterVehicule"
                                                     oncomplete="handleCreerNouveauModelRequest(xhr, status, args)"
                                                     >
                                        <f:setPropertyActionListener value="#{vehiculeCreerBean.cvTypemodel}" target="#{vehiculeEditBean.cvVehiculeSelectionner.typemodel}"/>
                                    </p:commandButton>

                                </p:panelGrid>   
                            </h:form>
                        </p:dialog>
                    </h:form >
                    <script type="text/javascript">
                        function handleCreerNouveauModelRequest(xhr, status, args) {
                            if (args.validationFailed || !args.status) {
                                //alert(args.message);
                            } else {
                                changementModeleDialog.hide();

                            }
                        }
                    </script>
                </ui:define>
            </ui:composition>
        </h:body>

    </f:view>
</html>

